package ru.ifmo.croak.sample;

import ru.ifmo.croak.api.MessageQuery;
import ru.ifmo.croak.api.QueryRequest;
import ru.ifmo.croak.api.QueryService;

import java.util.logging.Logger;

/**
 * Sample implementation of {@link QueryService} that provides some random messages.
 *
 * @author Roman Elizarov
 */
public class QueryServiceImpl implements QueryService {
    private final String name;
    private final Logger log;

    public QueryServiceImpl(String name) {
        this.name = name;
        log = Logger.getLogger(name);
    }

    public MessageQuery createQuery(QueryRequest request) {
        log.info("Creating query for " + request);
        MessageQueryImpl query = new MessageQueryImpl(request, name);
        query.start();
        return query;
    }
}
